﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using TLT.Models.Entities;
using TLT.Models.Configuration;



namespace TLT.Models.ShopruviDatabase
{
    public class ShopruviContext : DbContext
    {
        public DbSet<LoaiDoiTuong> LoaiDoiTuong { get; set; }
        public DbSet<DanToc> DanToc { get; set; }
        public DbSet<DonViTinh> DonViTinh { get; set; }
        public DbSet<HangSanXuat> HangSanXuat { get; set; }
        public DbSet<NhomKhachHang> NhomKhachHang { get; set; }
        public DbSet<KhachHang> KhachHang { get; set; }
        public DbSet<NhaVanChuyen> NhaVanChuyen { get; set; }
        public DbSet<KhachHangTaiKhoan> KhachHangTaiKhoan { get; set; }
        public DbSet<Kho> Kho { get; set; }
        public DbSet<KhuVuc> KhuVuc { get; set; }
        public DbSet<KichCo> KichCo { get; set; }
        public DbSet<MauSac> MauSac { get; set; }
        public DbSet<LoaiSanPham> LoaiSanPham { get; set; }
        public DbSet<SanPham> SanPham { get; set; }
        public DbSet<SanPhamHinhAnh> SanPhamHinhAnh { get; set; }
        public DbSet<LoHangNhap> LoHangNhap { get; set; }
        public DbSet<NganHang> NganHang { get; set; }
        public DbSet<NguonHang> NguonHang { get; set; }
        public DbSet<NhaCungCap> NhaCungCap { get; set; }
        public DbSet<NhaCungCapTaiKhoan> NhaCungCapTaiKhoan { get; set; }
        public DbSet<NhanVien> NhanVien { get; set; }
        public DbSet<NhomSanPham> NhomSanPham { get; set; }
        public DbSet<XaQuanHuyenThanhPho> XaQuanHuyenThanhPho { get; set; }
        public DbSet<ThongTinCongTy> ThongTinCongTy { get; set; }
        public DbSet<TonGiao> TonGiao { get; set; }

        // Mua Hàng
        public DbSet<DonDatHangNCC> DonDatHangNCC { get; set; }
        public DbSet<DonDatHangNCCChiTiet> DonDatHangNCCChiTiet { get; set; }

        //Hệ thống
        public DbSet<NhomNguoiDung> NhomNguoiDung { get; set; }

        public ShopruviContext() : base("name=ShopruviContextConnectionString")
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<ShopruviContext>());
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Conventions.Add(new TLTConvention());

            modelBuilder.Configurations.Add(new LoaiDoiTuongConfiguration());
            modelBuilder.Configurations.Add(new DanTocConfiguration());
            modelBuilder.Configurations.Add(new DonViTinhConfiguration());
            modelBuilder.Configurations.Add(new HangSanXuatConfiguration());
            modelBuilder.Configurations.Add(new KhachHangConfiguration());
            modelBuilder.Configurations.Add(new KhachHangTaiKhoanConfiguration());
            modelBuilder.Configurations.Add(new KhoConfiguration());
            modelBuilder.Configurations.Add(new KhuVucConfiguration());
            modelBuilder.Configurations.Add(new KichCoConfiguration());
            modelBuilder.Configurations.Add(new MauSacConfiguration());
            modelBuilder.Configurations.Add(new LoaiSanPhamConfiguration());
            modelBuilder.Configurations.Add(new LoHangNhapConfiguration());
            modelBuilder.Configurations.Add(new NganHangConfiguration());
            modelBuilder.Configurations.Add(new NguonHangConfiguration());
            modelBuilder.Configurations.Add(new NhaCungCapConfiguration());
            modelBuilder.Configurations.Add(new NhaCungCapTaiKhoanConfiguration());
            modelBuilder.Configurations.Add(new NhanVienConfiguration());
            modelBuilder.Configurations.Add(new NhaVanChuyenConfiguration());
            modelBuilder.Configurations.Add(new NhomKhachHangConfiguration());
            modelBuilder.Configurations.Add(new NhomNguoiDungConfiguration());
            modelBuilder.Configurations.Add(new NhomSanPhamConfiguration());
            modelBuilder.Configurations.Add(new SanPhamConfiguration());
            modelBuilder.Configurations.Add(new SanPhamHinhAnhConfiguration());
            modelBuilder.Configurations.Add(new ThongTinCongTyConfiguration());
            modelBuilder.Configurations.Add(new XaQuanHuyenThanhPhoConfiguration());
            modelBuilder.Configurations.Add(new TonGiaoConfiguration());

            // Mua Hàng
            modelBuilder.Configurations.Add(new DonDatHangNCCConfiguration());
            modelBuilder.Configurations.Add(new DonDatHangNCCChiTietConfiguration());
        } 
    }
}
